<?php

namespace app\api\controller;

use addons\shopro\model\Area;
use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }
    /**
     * 方案接口：1=用户协议、2=隐私协议
     */
    public function richtext($id){
        $richtext = Db::name('richtext')->find($id);
        $this->success('成功',$richtext);
    }
    /**
     * Banner接口
     */
    public function banner(){
        $banner = Db::name('banner')->field('id,title,image,type,path')->select();
        $this->success('成功',$banner);
    }
    public function message(){
        $messages= Db::name('system_message')->field('id,title,detail,createtime')->paginate();
        $this->success('消息列表',$messages);
    }
    public function message_detail($id){
        $message= Db::name('system_message')->find($id);
        $this->success('消息',$message);
    }
    public function area(){
        $list=Area::with(['children.children'])-> where('pid',0)->select();
        $this->success('地区三级',$list);
    }
    public function level(){
        $data= Db::name('level')->field('id,name,level,score,ratio')->select();
        $this->success('等级列表',$data);
    }
    public function column($type=1){
        //$type=1 经典赛事，2 经典节目
        $data= Db::name('column')->field('id,name,icon_image,image,weigh,createtime')->where('type',$type)->where('switch',1)->order('weigh','desc')->order('id')->paginate();
        $this->success('专栏列表',$data);
    }
}
